home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 110 / EnigmaAmiga110CD.iso / dalla rivista / host contacted / ksc_oldicons.lha / OldIcons.asm < prev    next >
Assembly Source File  |  2000-02-21  |  4KB  |  134 lines

  1. ; OldIcons v1.3: removes borders from icons.
  2. ; by Kyzer/CSG
  3. ; $VER: OldIcons 1.3 (20.08.99)
  4. ;
  5. ; based on NoIconBorder by Kamel Biskri / David Jones
  6. ;
  7.     incdir    include:
  8.     include    exec/execbase.i
  9.     include    lvo/exec_lib.i
  10.     include    lvo/graphics_lib.i
  11.  
  12. EXECBASE equr A6
  13. GFXBASE equr A5
  14.  
  15. START    move.l    4.w,EXECBASE
  16.     lea    gfxname(pc),a1
  17.     moveq    #36,d0
  18.     jsr    _LVOOpenLibrary(a6)    ; open graphics.library
  19.     tst.l    d0
  20.     beq.s    .quit
  21.     move.l    d0,GFXBASE
  22.  
  23. ; Our second code hunk contains the patch code.
  24.  
  25. ; START-4 contains a BPTR to the next hunk in our code.
  26. ; if we clear this pointer, DOS can't know we have a second code hunk,
  27. ; and won't free it. Therefore, the patch code will stay in memory.
  28. ;
  29. ; We'll also save relocs by addressing the second hunk relatively.
  30.  
  31.     lea    START-4(pc),a0
  32.     move.l    (a0),a4
  33.     clr.l    (a0)    ; remove pointer to second hunk
  34.     adda.l    a4,a4
  35.     adda.l    a4,a4
  36.     addq.l    #4,a4    ; a4 is now a pointer to PATCHES
  37.  
  38. ; set up the initial values for the Workbench task check in the patches
  39.     jsr    update-PATCHES(a4)
  40.  
  41. ; now we install the 3 patches.
  42.  
  43.     jsr    _LVOForbid(a6)    ; We Forbid() until we have set everything up
  44.  
  45. patch    macro ; name, function, base
  46.     lea    \1patch-PATCHES(a4),a1    ; get pointer to patch function
  47.     move.l    a1,d0
  48.     move.w    #_LVO\2,a0        ; set function offset
  49.     move.l    \3,a1            ; and library base
  50.     jsr    _LVOSetFunction(a6)    ; install the patch
  51.     move.l    d0,\1jmp+2-PATCHES(a4)    ; put old function ptr into patch code
  52.     endm
  53.  
  54.     patch    task, AddTask, EXECBASE
  55.     patch    rect, RectFill, GFXBASE
  56.     patch    draw, Draw, GFXBASE
  57.  
  58.     jsr    _LVOPermit(a6)    ; We also *must* Permit(). Thanks, Dave!
  59.  
  60. .quit    moveq    #0,d0
  61.     rts
  62.  
  63. gfxname    dc.b    'graphics.library',0
  64.  
  65. ;------------------------------------------------------------------------------
  66.     section    "patches",code
  67. PATCHES
  68.  
  69. ; a patch on Draw() and RectFill()
  70. ; these graphics functions are normally carried out, except in the following
  71. ; cases: 
  72. ; - ThisTask == Workbench (other tasks are not affected)
  73. ; - 8(sp) == 8  (??? means Workbench is drawing icon borders, not windows?)
  74.  
  75. drawpatch
  76.     cmp.l    #8,8(sp)    ; call original function if 8(sp) != 8
  77.     bne.s    drawjmp
  78. WBTEST    cmp.l    #1,$ABCDEF    ; this instruction set by call to update()
  79.     bne.s    drawjmp        ; call original function if not Workbench
  80.     rts            ; if Workbench/icon, don't draw lines
  81. drawjmp    jmp    $12345
  82.  
  83.     cnop    0,8
  84. rectpatch
  85.  
  86.     cmp.l    #8,8(sp)    ; call original function if 8(sp) != 8
  87.     bne.s    rectjmp
  88. WBTEST2    cmp.l    #1,$ABCDEF    ; this instruction set by call to update()
  89.     bne.s    rectjmp        ; call original function if not Workbench
  90.     addq.l    #3,d0        ; if Workbench/icon, 'alter' the rectangle
  91.     addq.l    #2,d1        ; filled to skip the borders.
  92.     subq.l    #3,d2
  93.     subq.l    #2,d3
  94. rectjmp    jmp    $12345
  95.  
  96. ; a patch on AddTask() - after a new task is added, we always update the
  97. ; Workbench task pointer, in case a new copy of Workbench is loaded.
  98. taskpatch
  99. taskjmp    jsr    $12345
  100.     movem.l    d0-d1/a0-a2,-(sp)
  101.     bsr.s    update
  102.     movem.l    (sp)+,d0-d1/a0-a2
  103.     rts
  104.  
  105. ; update: this code updates the addresses of Workbench and ThisTask in
  106. ; the graphics patches. Also clears caches.
  107. ; It's called once at installation time, and after every AddTask()
  108. update    jsr    _LVOForbid(a6)
  109.  
  110.     lea    TaskWait(a6),a0
  111.     bsr.s    .find
  112.     tst.l    d0
  113.     bne.s    .got
  114.     lea    TaskReady(a6),a0
  115.     bsr.s    .find
  116.  
  117. .got    lea    ThisTask(a6),a1
  118.  
  119.     lea    WBTEST+2(pc),a2
  120.     move.l    d0,(a2)+    ; store current Workbench task or NULL
  121.     move.l    a1,(a2)+    ; store address of execbase/ThisTask
  122.  
  123.     lea    WBTEST2+2(pc),a2
  124.     move.l    d0,(a2)+    ; store current Workbench task or NULL
  125.     move.l    a1,(a2)+    ; store address of execbase/ThisTask
  126.  
  127.     jsr    _LVOCacheClearU(a6)
  128.     jmp    _LVOPermit(a6)
  129.  
  130. .find    lea    .wbname(pc),a1
  131.     jmp    _LVOFindName(a6)
  132.  
  133. .wbname    dc.b    'Workbench',0
  134.